#ifndef _WRITE_DLEX_HEADER
#define _WRITE_DLEX_HEADER

#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>

// build interface file	///////////////////////////////////////
namespace parse_loc {
	class Write_failed {};
	void write_dlex_header(std::ostream &out, const std::string &ret_type) {
		std::ifstream in("c:\\dlex\\code\\dlex.h");
		if( !in ) {
			throw Write_failed();
		}
		std::string s;
		char c;
		bool first_int= ((ret_type =="int") ? false : true);// need to scan?
		while( in.get(c) ) {
			if( c == 'i' && first_int) {		// first 'int'?
				in >> s;
				if( s == "nt" )	{	// is 'int'?
					out << ret_type;
					first_int=false;
				} else {
					out << c;
					out << s;
				}
			} else
				out << c;
		}
	}			
}
namespace parse_loc {
	void init_dlex_header(std::ostream &out){
		out << "#ifndef _DLEX_DEC\n";
		out << "#define _DLEX_DEC\n";
	}
}
#endif
